package com.ty.day5;

import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 * Author : txy
 * Create 2023/11/1 16:10
 */
public class Five {
    public static void main(String[] args) {
        int[] a = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = sc.nextInt();
        if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0) {
            a[1]++;
        }
        System.out.println("请输入月份：");

        int month = sc.nextInt();
        while (month <= 0 || month > 12) {
            System.out.println("请输入月份：");
            month = sc.nextInt();
        }
        System.out.println("请输入号数：");
        int day = sc.nextInt();
        while (day <= 0 || day > a[month - 1]) {
            System.out.println("请输入号数：");
            day = sc.nextInt();
        }
        int count = 0;
        for (int i = 0; i < month - 1; i++) {
            count = count + a[i];
        }
        count = count + day;
        System.out.println(year + "年" + month + "月" + day + "号" + "有" + count + "天");
    }
}
